package cn.kgc.user.pojo;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * Created by teacher ZHANG on 2022/12/9
 */
//监听器（消费者:监听消息队列中有无消息）
@Component
public class MsgListener implements MessageListener {
    @Override
    public void onMessage(Message message, byte[] pattern) {
        String msg = message.toString();
        String [] items = msg.split(":");

        System.out.println("向手机" + items[0] + "发送验证码: " + items[1]);
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("验证码发送完毕。");
    }
}
